package pl.put.miasi.agents;


import org.jbox2d.common.Vec2;
import org.jbox2d.common.XForm;

import pl.put.miasi.volleyball.Volleyball;

/**
 * Model of GUI in MVC
 * @author root
 *
 */
public class GUI {

	public Volleyball volleyball;
	
	public GUI(Volleyball volleyball) {
		this.volleyball = volleyball;
	}
	
	/**
	 * Moves player on GUI
	 * @param agent
	 */
	public synchronized void movePlayer(PlayerAgent agent, Vec2 velocity) {
		//physically change values in robot parameters
		//so they can be read in step method and robots moved accordingly
		volleyball.parent.movePlayer(agent.number, velocity);
	}
	
	/**
	 * Moves player's arm on GUI
	 * @param agent
	 * @param volocity
	 */
	public synchronized void movePlayerArm(PlayerAgent agent, float velocity) {
		//physically change values in robot parameters
		//so they can be read in step method and robots moved accordingly		
		volleyball.parent.moveRacket(agent.number, velocity);
	}
	
	/**
	 * Whether there is next round
	 * @return
	 */
	public synchronized boolean nextRound() {
		return false;
	}
	
	
	/**
	 * Return ball position and velocity
	 * @return
	 */
	public synchronized Vec2 checkBall() {
		return volleyball.ballBody.getPosition();
	}
	
	/**
	 * Get position of player on GUI
	 * @param agent
	 * @return
	 */
	public synchronized Vec2 getMyPosition(PlayerAgent agent) {
		return volleyball.b2Player[agent.number].getPosition();
	}
}
